# Maintainer: schuay <jakob.gruber@gmail.com>
# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: stonecrest <stonecrest[at]gmail[dot]com>
# Contributor: Chocobo1 <chocobo1 AT archlinux DOT net>

pkgname=mac
pkgver=10.08
_pkgver="${pkgver//./}"
pkgrel=1
pkgdesc='APE codec and decompressor'
arch=('loong64' 'x86_64')
url='https://www.monkeysaudio.com/index.html'
license=('custom')
depends=('glibc' 'gcc-libs')
makedepends=('cmake' 'python-html2text')
source=(
  "$pkgname-$pkgver.zip::https://monkeysaudio.com/files/MAC_${_pkgver}_SDK.zip"
  "$pkgname-$pkgver-license.html::https://www.monkeysaudio.com/license.html"
)
sha512sums=('0c96b6fa8da9d412679e8c9b43e98d475a650899694a9d085c3b0272775cf229bb09c7c4f24a18ab7ee5516d2d34f7acd59e4216aca8fe08ed04f75e33e29322'
            'cd2e6dd9d89044a8e4e125d035ebb933593bb6868f77607136c6897ed77606c71584ba3f5587e64b3f9a18277ba799d82cc12c91b146b952ee02beabe04d2fa5')
b2sums=('8385308893b7849dc1dc5501e2235f64b90fa741f3360090f1150cd7e49d8cad2273f4b69181fc15da9e10988d9e77251f56f7fbe42fa3cd5fb310ef2380ae05'
        '6f8ab6ca6e7b367a901c083c2390c1fd175cc0aee9b86b6280a7883797525172ad5f6e3b4293ca288009adc550cd1646a54b74bdbaae40759fa3be551d16de50')

build() {
  cmake \
    -S . \
    -B build \
    -D CMAKE_BUILD_TYPE='None' \
    -D CMAKE_INSTALL_PREFIX='/usr'

  cmake --build build

  # generate license
  html2text --ignore-links "$pkgname-$pkgver-license.html" \
    | sed -n '/^## License$/,$p' \
    > LICENSE.md
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE.md
}
